<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>操作类名</button>
    <div class="content">div标签</div>

    <script>
        // 获取元素
        var box = document.querySelector('div')
        var btn = document.querySelector('button')
        // 获取类名
        console.log(box.className)
        // 给按钮绑定点击事件
        btn.onclick = function(){
            // 设置div类名
            box.className = 'box'
        }
    </script>
</body>
</html>